<?php
/**
 * Created by JetBrains PhpStorm.
 * User: TuanVu
 * Date: 9/4/12
 * Time: 5:09 PM
 * To change this template use File | Settings | File Templates.
 */

/*
 * lấy danh sách thumbnail của sản phẩm và trả về chuỗi html
 */
    if(isset($_POST['post_id']) && isset($_POST['action']) && $_POST['action']=='get_image_thumbs'){

        $attachments = get_posts( array(
            'post_type' 	=> 'attachment',
            'numberposts' 	=> -1,
            'post_status' 	=> null,
            'post_parent' 	=> $_POST['post_id'],
            'post__not_in'	=> array( get_post_thumbnail_id() ),
            'post_mime_type'=> 'image',
            'orderby'		=> 'menu_order',
            'order'			=> 'ASC'
        ) );

        if ($attachments) {
            $loop = 0;
            $columns = apply_filters( 'woocommerce_product_thumbnails_columns', 3 );

            foreach ( $attachments as $key => $attachment ) {
                if ( get_post_meta( $attachment->ID, '_woocommerce_exclude_image', true ) == 1 )
                    continue;
                ?>
            <img data-thumb="<?php echo wp_get_attachment_url( $attachment->ID );?>" src="<?php echo wp_get_attachment_url( $attachment->ID );?>">
            <?php
                $loop++;
            }
        }
}